package com.walkline.travelassistant.dao;

import org.json.me.JSONObject;

import com.walkline.travelassistant.TravelAssistantException;
import com.walkline.travelassistant.TravelAssistantSDK;
import com.walkline.travelassistant.inf.Location;

public class TravelAssistantLocation extends TravelAssistantObject implements Location
{
	private String _address = "";
	private String _content_province = "";
	private String _content_city = "";
	private String _content_district = "";
	private String _content_street = "";
	private String _content_street_number = "";
	private String _content_city_code = "";
	private String _content_address = "";
	private String _content_point_x = "";
	private String _content_point_y = "";
	private int _status = 0;

	public TravelAssistantLocation(TravelAssistantSDK travelAssistant, JSONObject jsonObject) throws TravelAssistantException
	{
		super(travelAssistant, jsonObject);

		JSONObject locationObject = jsonObject;
		if (locationObject != null)
		{
			_address = locationObject.optString("address");
			_status = locationObject.optInt("status");

			if (!locationObject.isNull("content"))
			{
				JSONObject contentObject = locationObject.optJSONObject("content");
				if (contentObject != null)
				{
					_content_address = contentObject.optString("address");

					if (!contentObject.isNull("address_detail"))
					{
						JSONObject detailObject = contentObject.optJSONObject("address_detail");
						if (detailObject != null)
						{
							_content_province = detailObject.optString("province");
							_content_city = detailObject.optString("city");
							_content_district = detailObject.optString("district");
							_content_street = detailObject.optString("street");
							_content_street_number = detailObject.optString("street_number");
							_content_city_code = detailObject.optString("city_code");
						}
					}

					if (!contentObject.isNull("point"))
					{
						JSONObject pointObject = contentObject.optJSONObject("point");
						if (pointObject != null)
						{
							_content_point_x = pointObject.optString("x");
							_content_point_y = pointObject.optString("y");
						}
					}
				}
			}
		}
	}

	public String getAddress() {return _address;}

	public String getContentAddress() {return _content_address;}

	public String getContentProvince() {return _content_province;}

	public String getContentCity() {return _content_city;}

	public String getContentDistrict() {return _content_district;}

	public String getContentStreet() {return _content_street;}

	public String getContentStreetNumber() {return _content_street_number;}

	public String getContentCityCode() {return _content_city_code;}

	public String getContentAddressPointX() {return _content_point_x;}

	public String getgetContentAddressPointY() {return _content_point_y;}

	public int getStatus() {return _status;}
}